//
//  CTAlert.m
//  ArrayPay
//
//  Created by chentao on 16/7/27.
//  Copyright © 2016年 tao.chen. All rights reserved.
//

#import "CTAlert.h"
#import "RYCAlertView.h"
#import "CTAlertView.h"
@implementation CTAlert
#pragma mark AlertView 需要用户点击
//hint 需要用户操作后才消失

+ (void)showAlertViewWithMessage:(NSString *)message operation:(void (^)(NSInteger clickedIndex))operation
{
    CTAlertView *alertView=[[CTAlertView alloc] initWithTitle:@"" message:message delegate:nil buttonTitles:@"确定",nil];
    alertView.operation=operation;
    [alertView show];
}
+ (void)showAlertViewWithMessage:(NSString *)message buttonTitle:(NSString *)buttonTitle operation:(void (^)(NSInteger clickedIndex))operation
{
    CTAlertView *alertView=[[CTAlertView alloc] initWithTitle:@"" message:message delegate:nil buttonTitles:buttonTitle,nil];
    alertView.operation=operation;
    [alertView show];
}
+ (void)showAlertViewConfirmWithTitle:(NSString *)title message:(NSString *)message operation:(void (^)(NSInteger clickedIndex))operation confirmButtonTitle:(NSString *)confirmButtonTitle cancelButtonTitle:(NSString *)cancelButtonTitle
{
    CTAlertView *alertView=[[CTAlertView alloc] initWithTitle:title message:message delegate:nil buttonTitles:cancelButtonTitle,confirmButtonTitle,nil];
    alertView.operation=operation;
    [alertView show];
}

+ (void)showAlert:(NSString *)message operation:(void (^)(NSInteger clickedIndex))operation
{
    [RYCAlertView showHint:@"" message:message operation:^(NSInteger clickedIndex) {
        if (operation) {
            operation(clickedIndex);
        }
    }];
}

+ (void)showAlert:(NSString *)title message:(NSString *)message operation:(void (^)(NSInteger clickedIndex))operation confirmButtonTitle:(NSString *)confirmButtonTitle cancelButtonTitle:(NSString *)cancelButtonTitle
{
    RYCAlertView* alertView = [[RYCAlertView alloc] initWithTitle:title message:message delegate:nil cancelButtonTitle:cancelButtonTitle otherButtonTitles:confirmButtonTitle, nil];
    [alertView showWithOperation:^(NSInteger clickedIndex) {
        if (operation) {
            operation(clickedIndex);
        }
    }];
}
+ (void)showAlertTextFieldWithTitle:(NSString *)title placeholder:(NSString *)placeholder textFieldOperation:(void (^)(NSInteger clickedIndex,NSString *text))textFieldOperation confirmButtonTitle:(NSString *)confirmButtonTitle cancelButtonTitle:(NSString *)cancelButtonTitle
{
    CTAlertView *alertView=[[CTAlertView alloc] initTextFieldWithTitle:title placeholder:placeholder delegate:nil buttonTitles:cancelButtonTitle,confirmButtonTitle,nil];
    alertView.textFieldOperation=textFieldOperation;
    [alertView show];
}
@end
